-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Align webpack's outputPath with the whole app #1194
Conversation
We hard-code webpack's output path to be the "assets" subdirectory of the built app (which appears as "./dist/assets" after you run a build). This is needlessly confusing and limiting, because webpack's view of the world doesn't match what the app author actually writes. Mostly this doesn't matter when people are using all the defaults, but if they wanted to customize (for example) the location of the generated chunks they can't escape the assets subdir. This PR fixes this problem by setting webpack's `output.path` to the root of the (output) ember app (meaning the "./dist" subdir in a typical build), and making corresponding adjustments to `output.filename` and `output.chunkFileName` so that we're still producing the same files by default, but they're now addressed relative to the whole app.
chunkFilename: `chunk.[chunkhash].js`, | ||
publicPath: publicAssetURL + 'assets/', | ||
path: join(this.outputPath), | ||
filename: `assets/chunk.[chunkhash].js`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have existing tests to assert these files are created in this folder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests likethese are directly inspecting the output files.
And the various tests/scenarios are ensuring that these files actually execute.
webpackConfig: Configuration; | ||
|
||
// the base public URL for your assets in production. Use this when you want | ||
// to serve all your assets from a different origin (like a CDN) than your | ||
// actual index.html will be served on. | ||
// | ||
// This should be a URL ending in "/". | ||
// | ||
// For example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for adding additional docs + examples!
In #1194 we adjusted the webpack outputPath and made a compensating adjustment to the default JS chunk names so they would still end up in the same place. But we neglected to make a compensating change to the default chunk naming for production CSS chunks. This caused the chunks to unintentionally move up one level in the directory hierarchy. This doesn't break anything, but it's inconsistent. This PR puts them back inside "assets" like before.
In embroider-build#1194 we adjusted the webpack outputPath and made a compensating adjustment to the default JS chunk names so they would still end up in the same place. But we neglected to make a compensating change to the default chunk naming for production CSS chunks. This caused the chunks to unintentionally move up one level in the directory hierarchy. This doesn't break anything, but it's inconsistent. This PR puts them back inside "assets" like before.
We hard-code webpack's output path to be the "assets" subdirectory of the built app (which appears as "./dist/assets" after you run a build).
This is needlessly confusing and limiting, because webpack's view of the world doesn't match what the app author actually writes. Mostly this doesn't matter when people are using all the defaults, but if they wanted to customize (for example) the location of the generated chunks they can't escape the assets subdir.
This PR fixes this problem by setting webpack's
output.path
to the root of the (output) ember app (meaning the "./dist" subdir in a typical build), and making corresponding adjustments tooutput.filename
andoutput.chunkFileName
so that we're still producing the same files by default, but they're now addressed relative to the whole app.This is fix for #1157.